Fuel ASM
Instruction set for the FuelVM.
Compile features
std
: Unless set, the crate will link to the core-crate instead of the std-crate. More info here.serde-types
: Add support for serde for the types exposed by this crate.serde-types-minimal
: Add support forno-std
serde for the types exposed by this crate.
Example
use *;
use *;
// A sample program to perform ecrecover
let program = vec!;
// Convert program to bytes representation
let bytes: = program.iter.copied.collect;
// A program can be reconstructed from an iterator of bytes
let restored = from_bytes_iter;
assert_eq!;
// Every instruction can be described as `u32` big-endian bytes
let halfwords: = program.iter.copied.map.collect;
let bytes = halfwords.iter.copied.map.flatten;
let restored = from_bytes_iter;
assert_eq!;
// We can also reconstruct the instructions individually
let restored: = halfwords.iter.copied.map.collect;
assert_eq!;
// We have an unchecked variant for optimal performance
let restored: = halfwords
.iter
.copied
.map
.collect;
assert_eq!;
// Finally, we have [`Instruction`] to allow optimal runtime parsing of the components of the
// opcode
//
// `Opcode` itself is only but an abstraction/helper to facilitate visualization, but the VM is
// expected to use raw instructions
let instrs: = program.iter.copied.map.collect;
let restored: = instrs.iter.copied.map.collect;
assert_eq!;
// An instruction is composed by the opcode representation registers Id and immediate values
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;